package com.hlkj.sellergoodsservice.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hlkj.common.common.PageResult;
import com.hlkj.pojo.model.Brand;
import com.hlkj.sellergoodsservice.mapper.BrandMapper;
import com.hlkj.sellergoodsservice.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BrandServiceImpl implements BrandService {

    @Resource
    private BrandMapper brandMapper;

    @Override
    public List<Brand> findAll() {
        return brandMapper.selectByExample(null);
    }

    @Override
    public PageResult findPage(Integer pageNo, Integer pageSize) {
        //分页查询控件
        PageHelper.startPage(pageNo,pageSize);
        //分页查询
        Page<Brand> page=(Page<Brand>)brandMapper.selectByExample(null);
        //返回结果转换
        return new PageResult(page.getTotal(),page.getResult());
    }
}
